package com.fruit.controller;

import com.fruit.message.StreamClient;
import com.fruit.model.OrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: LJ
 * @Date: 2018/11/2 16:35
 * @version:
 */
@RestController
public class SendMessageController {
    @Autowired
    private StreamClient streamClient;

//    @GetMapping("/sendMessage")
//    public  void  process(){
//        String message ="now "+ new Date();
//        streamClient.output().send(MessageBuilder.withPayload(message).build());
//    }

    /**
     * 发送
     */
    @GetMapping("/sendMessage")
    public  void  process(){
        OrderDTO orderDTO =new OrderDTO();
        orderDTO.setBuyerAddress("dsadada");
        orderDTO.setBuyerName("dasdsad");
        orderDTO.setBuyerPhone("测试");
        streamClient.output().send(MessageBuilder.withPayload(orderDTO).build());
    }
}
